Optimal. Leaf size=285 \[ -\frac{2 \left (a^2 c+2 a b d-b^2 c\right ) \left (a^2 (-d)+2 a b c+b^2 d\right ) \log (\cos (e+f x))}{f \left (c^2+d^2\right )^2}+\frac{x \left (-6 a^2 b^2 \left (c^2-d^2\right )+8 a^3 b c d+a^4 \left (c^2-d^2\right )-8 a b^3 c d+b^4 \left (c^2-d^2\right )\right )}{\left (c^2+d^2\right )^2}-\frac{b^2 \left (a d (2 b c-a d)-b^2 \left (2 c^2+d^2\right )\right ) \tan (e+f x)}{d^2 f \left (c^2+d^2\right )}-\frac{(b c-a d)^2 (a+b \tan (e+f x))^2}{d f \left (c^2+d^2\right ) (c+d \tan (e+f x))}-\frac{2 \left (a c d+b \left (c^2+2 d^2\right )\right ) (b c-a d)^3 \log (c+d \tan (e+f x))}{d^3 f \left (c^2+d^2\right )^2} \]
[Out]
________________________________________________________________________________________
Rubi [A] time = 0.804243, antiderivative size = 285, normalized size of antiderivative = 1., number of steps used = 6, number of rules used = 6, integrand size = 25, \(\frac{\text{number of rules}}{\text{integrand size}}\) = 0.24, Rules used = {3565, 3637, 3626, 3617, 31, 3475} \[ -\frac{2 \left (a^2 c+2 a b d-b^2 c\right ) \left (a^2 (-d)+2 a b c+b^2 d\right ) \log (\cos (e+f x))}{f \left (c^2+d^2\right )^2}+\frac{x \left (-6 a^2 b^2 \left (c^2-d^2\right )+8 a^3 b c d+a^4 \left (c^2-d^2\right )-8 a b^3 c d+b^4 \left (c^2-d^2\right )\right )}{\left (c^2+d^2\right )^2}-\frac{b^2 \left (a d (2 b c-a d)-b^2 \left (2 c^2+d^2\right )\right ) \tan (e+f x)}{d^2 f \left (c^2+d^2\right )}-\frac{(b c-a d)^2 (a+b \tan (e+f x))^2}{d f \left (c^2+d^2\right ) (c+d \tan (e+f x))}-\frac{2 \left (a c d+b \left (c^2+2 d^2\right )\right ) (b c-a d)^3 \log (c+d \tan (e+f x))}{d^3 f \left (c^2+d^2\right )^2} \]
Antiderivative was successfully verified.
[In]
[Out]
Rule 3565
Rule 3637
Rule 3626
Rule 3617
Rule 31
Rule 3475
Rubi steps
\begin{align*} \int \frac{(a+b \tan (e+f x))^4}{(c+d \tan (e+f x))^2} \, dx &=-\frac{(b c-a d)^2 (a+b \tan (e+f x))^2}{d \left (c^2+d^2\right ) f (c+d \tan (e+f x))}+\frac{\int \frac{(a+b \tan (e+f x)) \left (2 b^3 c^2+a^3 c d-5 a b^2 c d+4 a^2 b d^2+d \left (3 a^2 b c-b^3 c-a^3 d+3 a b^2 d\right ) \tan (e+f x)-b \left (a d (2 b c-a d)-b^2 \left (2 c^2+d^2\right )\right ) \tan ^2(e+f x)\right )}{c+d \tan (e+f x)} \, dx}{d \left (c^2+d^2\right )}\\ &=-\frac{b^2 \left (a d (2 b c-a d)-b^2 \left (2 c^2+d^2\right )\right ) \tan (e+f x)}{d^2 \left (c^2+d^2\right ) f}-\frac{(b c-a d)^2 (a+b \tan (e+f x))^2}{d \left (c^2+d^2\right ) f (c+d \tan (e+f x))}-\frac{\int \frac{-4 a b^3 c^2 d-a^4 c d^2+6 a^2 b^2 c d^2-4 a^3 b d^3+b^4 c \left (2 c^2+d^2\right )-d^2 \left (4 a^3 b c-4 a b^3 c-a^4 d+6 a^2 b^2 d-b^4 d\right ) \tan (e+f x)+2 b^3 (b c-2 a d) \left (c^2+d^2\right ) \tan ^2(e+f x)}{c+d \tan (e+f x)} \, dx}{d^2 \left (c^2+d^2\right )}\\ &=\frac{\left (8 a^3 b c d-8 a b^3 c d+a^4 \left (c^2-d^2\right )-6 a^2 b^2 \left (c^2-d^2\right )+b^4 \left (c^2-d^2\right )\right ) x}{\left (c^2+d^2\right )^2}-\frac{b^2 \left (a d (2 b c-a d)-b^2 \left (2 c^2+d^2\right )\right ) \tan (e+f x)}{d^2 \left (c^2+d^2\right ) f}-\frac{(b c-a d)^2 (a+b \tan (e+f x))^2}{d \left (c^2+d^2\right ) f (c+d \tan (e+f x))}+\frac{\left (2 \left (a^2 c-b^2 c+2 a b d\right ) \left (2 a b c-a^2 d+b^2 d\right )\right ) \int \tan (e+f x) \, dx}{\left (c^2+d^2\right )^2}-\frac{\left (2 (b c-a d)^3 \left (a c d+b \left (c^2+2 d^2\right )\right )\right ) \int \frac{1+\tan ^2(e+f x)}{c+d \tan (e+f x)} \, dx}{d^2 \left (c^2+d^2\right )^2}\\ &=\frac{\left (8 a^3 b c d-8 a b^3 c d+a^4 \left (c^2-d^2\right )-6 a^2 b^2 \left (c^2-d^2\right )+b^4 \left (c^2-d^2\right )\right ) x}{\left (c^2+d^2\right )^2}-\frac{2 \left (a^2 c-b^2 c+2 a b d\right ) \left (2 a b c-a^2 d+b^2 d\right ) \log (\cos (e+f x))}{\left (c^2+d^2\right )^2 f}-\frac{b^2 \left (a d (2 b c-a d)-b^2 \left (2 c^2+d^2\right )\right ) \tan (e+f x)}{d^2 \left (c^2+d^2\right ) f}-\frac{(b c-a d)^2 (a+b \tan (e+f x))^2}{d \left (c^2+d^2\right ) f (c+d \tan (e+f x))}-\frac{\left (2 (b c-a d)^3 \left (a c d+b \left (c^2+2 d^2\right )\right )\right ) \operatorname{Subst}\left (\int \frac{1}{c+x} \, dx,x,d \tan (e+f x)\right )}{d^3 \left (c^2+d^2\right )^2 f}\\ &=\frac{\left (8 a^3 b c d-8 a b^3 c d+a^4 \left (c^2-d^2\right )-6 a^2 b^2 \left (c^2-d^2\right )+b^4 \left (c^2-d^2\right )\right ) x}{\left (c^2+d^2\right )^2}-\frac{2 \left (a^2 c-b^2 c+2 a b d\right ) \left (2 a b c-a^2 d+b^2 d\right ) \log (\cos (e+f x))}{\left (c^2+d^2\right )^2 f}-\frac{2 (b c-a d)^3 \left (a c d+b \left (c^2+2 d^2\right )\right ) \log (c+d \tan (e+f x))}{d^3 \left (c^2+d^2\right )^2 f}-\frac{b^2 \left (a d (2 b c-a d)-b^2 \left (2 c^2+d^2\right )\right ) \tan (e+f x)}{d^2 \left (c^2+d^2\right ) f}-\frac{(b c-a d)^2 (a+b \tan (e+f x))^2}{d \left (c^2+d^2\right ) f (c+d \tan (e+f x))}\\ \end{align*}
Mathematica [C] time = 6.892, size = 1789, normalized size = 6.28 \[ \frac{2 \left (-i b^4 d^2 c^{10}-b^4 d^3 c^9+2 i a b^3 d^3 c^9-3 i b^4 d^4 c^8+2 a b^3 d^4 c^8-3 b^4 d^5 c^7+8 i a b^3 d^5 c^7-2 i a^3 b d^5 c^7+i a^4 d^6 c^6-2 i b^4 d^6 c^6+8 a b^3 d^6 c^6-6 i a^2 b^2 d^6 c^6-2 a^3 b d^6 c^6+a^4 d^7 c^5-2 b^4 d^7 c^5+6 i a b^3 d^7 c^5-6 a^2 b^2 d^7 c^5+i a^4 d^8 c^4+6 a b^3 d^8 c^4-6 i a^2 b^2 d^8 c^4+a^4 d^9 c^3-6 a^2 b^2 d^9 c^3+2 i a^3 b d^9 c^3+2 a^3 b d^{10} c^2\right ) (e+f x) \cos ^2(e+f x) (c \cos (e+f x)+d \sin (e+f x))^2 (a+b \tan (e+f x))^4}{c^2 (c-i d)^4 (c+i d)^3 d^5 f (a \cos (e+f x)+b \sin (e+f x))^4 (c+d \tan (e+f x))^2}-\frac{2 i \left (-b^4 c^5+2 a b^3 d c^4-2 b^4 d^2 c^3+6 a b^3 d^3 c^2-2 a^3 b d^3 c^2+a^4 d^4 c-6 a^2 b^2 d^4 c+2 a^3 b d^5\right ) \tan ^{-1}(\tan (e+f x)) \cos ^2(e+f x) (c \cos (e+f x)+d \sin (e+f x))^2 (a+b \tan (e+f x))^4}{d^3 \left (c^2+d^2\right )^2 f (a \cos (e+f x)+b \sin (e+f x))^4 (c+d \tan (e+f x))^2}-\frac{2 \left (2 a b^3 d-b^4 c\right ) \cos ^2(e+f x) \log (\cos (e+f x)) (c \cos (e+f x)+d \sin (e+f x))^2 (a+b \tan (e+f x))^4}{d^3 f (a \cos (e+f x)+b \sin (e+f x))^4 (c+d \tan (e+f x))^2}+\frac{\left (-b^4 c^5+2 a b^3 d c^4-2 b^4 d^2 c^3+6 a b^3 d^3 c^2-2 a^3 b d^3 c^2+a^4 d^4 c-6 a^2 b^2 d^4 c+2 a^3 b d^5\right ) \cos ^2(e+f x) \log \left ((c \cos (e+f x)+d \sin (e+f x))^2\right ) (c \cos (e+f x)+d \sin (e+f x))^2 (a+b \tan (e+f x))^4}{d^3 \left (c^2+d^2\right )^2 f (a \cos (e+f x)+b \sin (e+f x))^4 (c+d \tan (e+f x))^2}+\frac{\cos (e+f x) (c \cos (e+f x)+d \sin (e+f x)) \left (2 b^4 \sin (2 (e+f x)) c^6+b^4 d c^5-b^4 d \cos (2 (e+f x)) c^5-4 a b^3 d \sin (2 (e+f x)) c^5+a^4 d^2 (e+f x) c^4+b^4 d^2 (e+f x) c^4-6 a^2 b^2 d^2 (e+f x) c^4+a^4 d^2 (e+f x) \cos (2 (e+f x)) c^4+b^4 d^2 (e+f x) \cos (2 (e+f x)) c^4-6 a^2 b^2 d^2 (e+f x) \cos (2 (e+f x)) c^4+3 b^4 d^2 \sin (2 (e+f x)) c^4+6 a^2 b^2 d^2 \sin (2 (e+f x)) c^4+2 b^4 d^3 c^3-8 a b^3 d^3 (e+f x) c^3+8 a^3 b d^3 (e+f x) c^3-2 b^4 d^3 \cos (2 (e+f x)) c^3-8 a b^3 d^3 (e+f x) \cos (2 (e+f x)) c^3+8 a^3 b d^3 (e+f x) \cos (2 (e+f x)) c^3-4 a b^3 d^3 \sin (2 (e+f x)) c^3-4 a^3 b d^3 \sin (2 (e+f x)) c^3+a^4 d^3 (e+f x) \sin (2 (e+f x)) c^3+b^4 d^3 (e+f x) \sin (2 (e+f x)) c^3-6 a^2 b^2 d^3 (e+f x) \sin (2 (e+f x)) c^3-a^4 d^4 (e+f x) c^2-b^4 d^4 (e+f x) c^2+6 a^2 b^2 d^4 (e+f x) c^2-a^4 d^4 (e+f x) \cos (2 (e+f x)) c^2-b^4 d^4 (e+f x) \cos (2 (e+f x)) c^2+6 a^2 b^2 d^4 (e+f x) \cos (2 (e+f x)) c^2+a^4 d^4 \sin (2 (e+f x)) c^2+b^4 d^4 \sin (2 (e+f x)) c^2+6 a^2 b^2 d^4 \sin (2 (e+f x)) c^2-8 a b^3 d^4 (e+f x) \sin (2 (e+f x)) c^2+8 a^3 b d^4 (e+f x) \sin (2 (e+f x)) c^2+b^4 d^5 c-b^4 d^5 \cos (2 (e+f x)) c-4 a^3 b d^5 \sin (2 (e+f x)) c-a^4 d^5 (e+f x) \sin (2 (e+f x)) c-b^4 d^5 (e+f x) \sin (2 (e+f x)) c+6 a^2 b^2 d^5 (e+f x) \sin (2 (e+f x)) c+a^4 d^6 \sin (2 (e+f x))\right ) (a+b \tan (e+f x))^4}{2 c (c-i d)^2 (c+i d)^2 d^2 f (a \cos (e+f x)+b \sin (e+f x))^4 (c+d \tan (e+f x))^2} \]
Antiderivative was successfully verified.
[In]
[Out]
________________________________________________________________________________________
Maple [B] time = 0.036, size = 891, normalized size = 3.1 \begin{align*} \text{result too large to display} \end{align*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Maxima [A] time = 1.73156, size = 505, normalized size = 1.77 \begin{align*} \frac{\frac{b^{4} \tan \left (f x + e\right )}{d^{2}} + \frac{{\left ({\left (a^{4} - 6 \, a^{2} b^{2} + b^{4}\right )} c^{2} + 8 \,{\left (a^{3} b - a b^{3}\right )} c d -{\left (a^{4} - 6 \, a^{2} b^{2} + b^{4}\right )} d^{2}\right )}{\left (f x + e\right )}}{c^{4} + 2 \, c^{2} d^{2} + d^{4}} - \frac{2 \,{\left (b^{4} c^{5} - 2 \, a b^{3} c^{4} d + 2 \, b^{4} c^{3} d^{2} - 2 \, a^{3} b d^{5} + 2 \,{\left (a^{3} b - 3 \, a b^{3}\right )} c^{2} d^{3} -{\left (a^{4} - 6 \, a^{2} b^{2}\right )} c d^{4}\right )} \log \left (d \tan \left (f x + e\right ) + c\right )}{c^{4} d^{3} + 2 \, c^{2} d^{5} + d^{7}} + \frac{{\left (2 \,{\left (a^{3} b - a b^{3}\right )} c^{2} -{\left (a^{4} - 6 \, a^{2} b^{2} + b^{4}\right )} c d - 2 \,{\left (a^{3} b - a b^{3}\right )} d^{2}\right )} \log \left (\tan \left (f x + e\right )^{2} + 1\right )}{c^{4} + 2 \, c^{2} d^{2} + d^{4}} - \frac{b^{4} c^{4} - 4 \, a b^{3} c^{3} d + 6 \, a^{2} b^{2} c^{2} d^{2} - 4 \, a^{3} b c d^{3} + a^{4} d^{4}}{c^{3} d^{3} + c d^{5} +{\left (c^{2} d^{4} + d^{6}\right )} \tan \left (f x + e\right )}}{f} \end{align*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Fricas [B] time = 2.79162, size = 1451, normalized size = 5.09 \begin{align*} -\frac{b^{4} c^{4} d^{2} - 4 \, a b^{3} c^{3} d^{3} + 6 \, a^{2} b^{2} c^{2} d^{4} - 4 \, a^{3} b c d^{5} + a^{4} d^{6} -{\left ({\left (a^{4} - 6 \, a^{2} b^{2} + b^{4}\right )} c^{3} d^{3} + 8 \,{\left (a^{3} b - a b^{3}\right )} c^{2} d^{4} -{\left (a^{4} - 6 \, a^{2} b^{2} + b^{4}\right )} c d^{5}\right )} f x -{\left (b^{4} c^{4} d^{2} + 2 \, b^{4} c^{2} d^{4} + b^{4} d^{6}\right )} \tan \left (f x + e\right )^{2} +{\left (b^{4} c^{6} - 2 \, a b^{3} c^{5} d + 2 \, b^{4} c^{4} d^{2} - 2 \, a^{3} b c d^{5} + 2 \,{\left (a^{3} b - 3 \, a b^{3}\right )} c^{3} d^{3} -{\left (a^{4} - 6 \, a^{2} b^{2}\right )} c^{2} d^{4} +{\left (b^{4} c^{5} d - 2 \, a b^{3} c^{4} d^{2} + 2 \, b^{4} c^{3} d^{3} - 2 \, a^{3} b d^{6} + 2 \,{\left (a^{3} b - 3 \, a b^{3}\right )} c^{2} d^{4} -{\left (a^{4} - 6 \, a^{2} b^{2}\right )} c d^{5}\right )} \tan \left (f x + e\right )\right )} \log \left (\frac{d^{2} \tan \left (f x + e\right )^{2} + 2 \, c d \tan \left (f x + e\right ) + c^{2}}{\tan \left (f x + e\right )^{2} + 1}\right ) -{\left (b^{4} c^{6} - 2 \, a b^{3} c^{5} d + 2 \, b^{4} c^{4} d^{2} - 4 \, a b^{3} c^{3} d^{3} + b^{4} c^{2} d^{4} - 2 \, a b^{3} c d^{5} +{\left (b^{4} c^{5} d - 2 \, a b^{3} c^{4} d^{2} + 2 \, b^{4} c^{3} d^{3} - 4 \, a b^{3} c^{2} d^{4} + b^{4} c d^{5} - 2 \, a b^{3} d^{6}\right )} \tan \left (f x + e\right )\right )} \log \left (\frac{1}{\tan \left (f x + e\right )^{2} + 1}\right ) -{\left (2 \, b^{4} c^{5} d - 4 \, a b^{3} c^{4} d^{2} - 4 \, a^{3} b c^{2} d^{4} + 2 \,{\left (3 \, a^{2} b^{2} + b^{4}\right )} c^{3} d^{3} +{\left (a^{4} + b^{4}\right )} c d^{5} +{\left ({\left (a^{4} - 6 \, a^{2} b^{2} + b^{4}\right )} c^{2} d^{4} + 8 \,{\left (a^{3} b - a b^{3}\right )} c d^{5} -{\left (a^{4} - 6 \, a^{2} b^{2} + b^{4}\right )} d^{6}\right )} f x\right )} \tan \left (f x + e\right )}{{\left (c^{4} d^{4} + 2 \, c^{2} d^{6} + d^{8}\right )} f \tan \left (f x + e\right ) +{\left (c^{5} d^{3} + 2 \, c^{3} d^{5} + c d^{7}\right )} f} \end{align*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Sympy [F(-2)] time = 0., size = 0, normalized size = 0. \begin{align*} \text{Exception raised: AttributeError} \end{align*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Giac [B] time = 2.54815, size = 795, normalized size = 2.79 \begin{align*} \frac{\frac{b^{4} \tan \left (f x + e\right )}{d^{2}} + \frac{{\left (a^{4} c^{2} - 6 \, a^{2} b^{2} c^{2} + b^{4} c^{2} + 8 \, a^{3} b c d - 8 \, a b^{3} c d - a^{4} d^{2} + 6 \, a^{2} b^{2} d^{2} - b^{4} d^{2}\right )}{\left (f x + e\right )}}{c^{4} + 2 \, c^{2} d^{2} + d^{4}} + \frac{{\left (2 \, a^{3} b c^{2} - 2 \, a b^{3} c^{2} - a^{4} c d + 6 \, a^{2} b^{2} c d - b^{4} c d - 2 \, a^{3} b d^{2} + 2 \, a b^{3} d^{2}\right )} \log \left (\tan \left (f x + e\right )^{2} + 1\right )}{c^{4} + 2 \, c^{2} d^{2} + d^{4}} - \frac{2 \,{\left (b^{4} c^{5} - 2 \, a b^{3} c^{4} d + 2 \, b^{4} c^{3} d^{2} + 2 \, a^{3} b c^{2} d^{3} - 6 \, a b^{3} c^{2} d^{3} - a^{4} c d^{4} + 6 \, a^{2} b^{2} c d^{4} - 2 \, a^{3} b d^{5}\right )} \log \left ({\left | d \tan \left (f x + e\right ) + c \right |}\right )}{c^{4} d^{3} + 2 \, c^{2} d^{5} + d^{7}} + \frac{2 \, b^{4} c^{5} d \tan \left (f x + e\right ) - 4 \, a b^{3} c^{4} d^{2} \tan \left (f x + e\right ) + 4 \, b^{4} c^{3} d^{3} \tan \left (f x + e\right ) + 4 \, a^{3} b c^{2} d^{4} \tan \left (f x + e\right ) - 12 \, a b^{3} c^{2} d^{4} \tan \left (f x + e\right ) - 2 \, a^{4} c d^{5} \tan \left (f x + e\right ) + 12 \, a^{2} b^{2} c d^{5} \tan \left (f x + e\right ) - 4 \, a^{3} b d^{6} \tan \left (f x + e\right ) + b^{4} c^{6} - 6 \, a^{2} b^{2} c^{4} d^{2} + 3 \, b^{4} c^{4} d^{2} + 8 \, a^{3} b c^{3} d^{3} - 8 \, a b^{3} c^{3} d^{3} - 3 \, a^{4} c^{2} d^{4} + 6 \, a^{2} b^{2} c^{2} d^{4} - a^{4} d^{6}}{{\left (c^{4} d^{3} + 2 \, c^{2} d^{5} + d^{7}\right )}{\left (d \tan \left (f x + e\right ) + c\right )}}}{f} \end{align*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]